package day11;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.concurrent.CountDownLatch;

import org.junit.Test;

public class JDBCTest2 {
	
	@Test
	public void testInsert() {
		Connection connection = null;
		PreparedStatement preparedStatement = null;
		
		try {
		connection = JDBCUtil.getConnection();
		String sql = "INSERT INTO student(`name`,age,gender) VALUES(?,?,?);";
			preparedStatement = connection.prepareStatement(sql);
		preparedStatement.setString(1, "张三1");
		preparedStatement.setInt(2, 23);
		preparedStatement.setString(3, "女");
		 
		int count = preparedStatement.executeUpdate();
		if (count == 1) {
			System.out.println("插入成功");
		}else {
			System.out.println("插入失败");
		}
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			JDBCUtil.close(connection, preparedStatement, null);
		}
		
		
	}

}
